/**
 * There are code generation
 */
package com.neusoft.lohas.modules.ivm.entity.workflow;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.neusoft.lohas.common.persistence.IdEntity;
import com.neusoft.lohas.modules.ivm.entity.order.Order;

/**
 * 流程Entity
 * @author Jackie.Liu
 * @version 2014-12-21
 */
@Entity
@Table(name = "ivm_workflow")
@DynamicInsert @DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class WorkFlow extends IdEntity<WorkFlow> {

	private static final long serialVersionUID = 1L;
	private String type;	//流程名称
	private	String status;	  //流程状态
	private Order order;
	private List<WorkFlowDetail> detailList = Lists.newArrayList(); // 流程明细
	
	public WorkFlow() {
		super();
	}

	public WorkFlow(String id){
		this();
		this.id = id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@OneToOne
	@JoinColumn(name="entity_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@JsonIgnore
	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}
	
	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "workFlow")
	@Where(clause="del_flag='"+DEL_FLAG_NORMAL+"'")
	@OrderBy("id")
	@NotFound(action = NotFoundAction.IGNORE)
	public List<WorkFlowDetail> getDetailList() {
		return detailList;
	}

	public void setDetailList(List<WorkFlowDetail> detailList) {
		this.detailList = detailList;
	}

}


